package com.kk.base.config.admin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.kk.base.constant.RuntimeConstant;
import com.kk.base.interceptor.admin.AdminAuthorityInterceptor;
import com.kk.base.interceptor.admin.AdminLoginInterceptor;

/**
 * 配置后台拦截器
 */
@Configuration
public class AdminWebConfig implements WebMvcConfigurer {

    @Autowired
    private AdminLoginInterceptor adminLoginInterceptor;

    @Autowired
    private AdminAuthorityInterceptor adminAuthorityInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(adminLoginInterceptor).addPathPatterns("/**")
                .excludePathPatterns(RuntimeConstant.loginExcludePathPatterns);
        registry.addInterceptor(adminAuthorityInterceptor).addPathPatterns("/**")
                .excludePathPatterns(RuntimeConstant.authorityExcludePathPatterns);
    }

}
